package com.lnkwe.util;


import com.lnkwe.constant.SessionConstant;
import com.lnkwe.sys.model.SysUser;
import com.lnkwe.user.model.User;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户信息
 * Created by lijing on 2016-03-11.
 */
public class UserUtil {

    public static SysUser getSysUser(HttpServletRequest request) {
        Object context=request.getSession().getAttribute(SessionConstant.SYSUSER);
        if (context != null && context instanceof SysUser){
            return (SysUser) context;
        }
        return null;
    }
    public static User getUser(HttpServletRequest request) {
        Object context=request.getSession().getAttribute(SessionConstant.USER);
        if (context != null && context instanceof User){
            return (User) context;
        }
        return null;
    }
    public static String getSysUserId(HttpServletRequest request) {
        SysUser sysUser=getSysUser(request);
        if(sysUser!=null){
            return sysUser.getId();
        }
        return "";
    }
}
